<?php

/**
 * VTNSCms form base class.
 *
 * @method VTNSCms getObject() Returns the current form's model object
 *
 * @package    emc
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseVTNSCmsForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'cms_id'          => new sfWidgetFormInputHidden(),
      'name'            => new sfWidgetFormInputText(),
      'name_vi'         => new sfWidgetFormInputText(),
      'cms_category_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('VTNSCmsCategory'), 'add_empty' => true)),
      'picture'         => new sfWidgetFormTextarea(),
      'picture_vi'      => new sfWidgetFormTextarea(),
      'description'     => new sfWidgetFormTextarea(),
      'description_vi'  => new sfWidgetFormTextarea(),
      'content'         => new sfWidgetFormTextarea(),
      'content_vi'      => new sfWidgetFormTextarea(),
      'link'            => new sfWidgetFormTextarea(),
      'views_count'     => new sfWidgetFormInputText(),
      'is_active'       => new sfWidgetFormInputText(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'cms_id'          => new sfValidatorChoice(array('choices' => array($this->getObject()->get('cms_id')), 'empty_value' => $this->getObject()->get('cms_id'), 'required' => false)),
      'name'            => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'name_vi'         => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'cms_category_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('VTNSCmsCategory'), 'required' => false)),
      'picture'         => new sfValidatorString(array('required' => false)),
      'picture_vi'      => new sfValidatorString(array('required' => false)),
      'description'     => new sfValidatorString(array('required' => false)),
      'description_vi'  => new sfValidatorString(array('required' => false)),
      'content'         => new sfValidatorString(array('required' => false)),
      'content_vi'      => new sfValidatorString(array('required' => false)),
      'link'            => new sfValidatorString(array('required' => false)),
      'views_count'     => new sfValidatorInteger(array('required' => false)),
      'is_active'       => new sfValidatorInteger(array('required' => false)),
      'created_at'      => new sfValidatorDateTime(),
      'updated_at'      => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('vtns_cms[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'VTNSCms';
  }

}
